package com.orange.lockscreen.layers.background;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;

import com.orange.lockscreen.layers.GenericSlat;

public class BackgroundSlat extends GenericSlat {

	public static final String	TAG	= "BackgroundSlat";
	private Bitmap				mWallPaperPieceBitmap;

	public BackgroundSlat(Context context) {
		super(context);
		init();
	}

	protected void init() {
		if (null != mWallPaperPieceBitmap) {
			this.setBackgroundDrawable(new BitmapDrawable(mWallPaperPieceBitmap));
		}
	}

	public Bitmap getSlatDrawCache() {
		return mWallPaperPieceBitmap;
	}

	public void setWallPaperPiece(Bitmap bitmap) {
		this.setBackgroundDrawable(null);
		if (null != mWallPaperPieceBitmap) {
			mWallPaperPieceBitmap.recycle();
		}
		mWallPaperPieceBitmap = bitmap;
		this.setBackgroundDrawable(new BitmapDrawable(mWallPaperPieceBitmap));
	}

	public void release() {
		this.setBackgroundDrawable(null);
		if (null != mWallPaperPieceBitmap) {
			mWallPaperPieceBitmap.recycle();
		}
	}
}
